<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/5/13
 * Time: 12:38
 */
header('Content-Type:application/json');
include "../classes/logincheck.php";
include '../classes/conn.php';
$class_num=$_POST['class_num'];
$sec_num=$_POST['sec_num'];
if(islogin()!='teacher_login'){
    die('error');
}

$query1="select num,name from section where class='{$class_num}' and num ='{$sec_num}' and teacher='{$_SESSION['t_num']}'";

$query2="select num,name from subsection where class='{$class_num}' and section ='{$sec_num}' and teacher='{$_SESSION['t_num']}'";
$sec=array();
$res1=mysql_query($query1);
while ($row=mysql_fetch_assoc($res1)){
    $sec['num'][]=$row['num'];
    $sec['name'][]=$row['name'];
}
$res2=mysql_query($query2);
while ($row=mysql_fetch_assoc($res2)){
    $sec['sub'][]=$row;
}
$data=json_encode($sec);
echo $data;